package com.example.caorl.job5thread.interrupt;

public class Runner1 implements Runnable {
   
    @Override
    public void run() {
        for (int i = 0; i < 1000000000; i++) {
            System.out.println("进入Runner1运行状态———————" + i);
            if(Thread.currentThread().isInterrupted()){ //加了这个还是有问题，可能打断的时候线程正则睡眠状态，也就是一直与下面的状态，那么打断还是会被catch
                //处理中断逻辑
                String name = Thread.currentThread().getName();
                System.out.println("--------线程退出-------" + name);
                break;
            }
            /*try {
                Thread.sleep(1000);
            } catch (InterruptedException e) { //外部无法用InterruptedException打断
                e.printStackTrace();
            }*/
        }
    }
}
